{extend name="template/base_default"}
{block name="header"}
<link rel="stylesheet" href="__CSS__/common.css">
<link rel="stylesheet" href="__CSS__/weui.min.css">
<link rel="stylesheet" href="__CSS__/index.css">
<link rel="stylesheet" href="__CSS__/weuix.min.css"/>
<script type="text/javascript" src="__JS__/boye-city-picker.js"></script>
<script type="text/javascript" src="__JS__/jquery-weui.min.js"></script>
<script src="__JS__/zepto.min.js"></script>
<script src="__JS__/lrz.min.js"></script>


<script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
<script src="__JS__/lodash.js"></script>
<link rel="stylesheet" href="__CSS__/editShop/style.css">
<style>

    .form-head{
        color: white;
        font-size: 16px;
        background-color: rgba(95, 110, 170, 0.4);
        border-radius: 5px;
        overflow: hidden;
        color:white;
        height:420px;
    }
    body{
        background-image:url("__IMG__/bj.png");
        background-size:cover;
        text-align: center;
        background-attachment:fixed;
    }
    .body-input{
        color: #dddddd;
        position: relative;
        outline: none;
        border: solid 1px #ffffff;
        background-color: rgba(255, 255, 255, 0);
        float: left;
        margin: auto;
        font-size: 16px;
        height: 41px;
        line-height: 41px;
        border-radius: 5px;
        width: 60%;
        font-family: "Microsoft YaHei UI";
    }
    .bottom-btn{
        width:50%;
        height:100%;
        float: left;
    }
    button{
        border: none;
        color:white;
    }
    .botton1{
        background-color: #FF0000;

    }
    .botton2{
        background-color: #131a34;
        width:100%;
    }
    .input-window{
        margin-left: auto;
        margin-right: auto;
        background-color: white;
        width:90%;
        height:150px;
        background-color: rgba(95, 110, 170, 0.4);
        border-radius: 10px;
        margin-top: 30px;
        margin-left: 20px;
        text-align: center;
        clear:both;
        position: relative;
    }
    .aa{
        height:3px;
        background-color: white;
        width:40px;
        position:absolute;
        top: 30px;
        left:55px;
    }
    .bb{

        opacity: 0;
        -webkit-tap-highlight-color: rgba(0,0,0,0);
        z-index:99;
        width:300px;
        position:absolute;
        top:0;
        left:0;
        height:140px;
    }
    li{
        list-style:none;
    }
    .store-box{

        height:90px;
        margin-top: 30px;
        width: 90%;
        color:#545454;
    }
    .form-input3-label{
        width:28%;
    }
    .store-box img {
        width:100px;
        height:100px;
        float:right;
        margin-right: 10px;
        margin-top: 10px;
    }
    .store-success{
        font-size: 18px;
        color:#545454;

        font-family: "Microsoft YaHei UI";
    }
    .store-text{
        float: left;
        margin-top: 30px;
        margin-left: 16px;
        text-align: left;

    }
    .store-detail{
        font-size: 14px;
        color:#8c8c8c;
        font-family: "Microsoft YaHei UI";
        margin-top: 12px;
    }
    .store-p{
        text-align: center;
        color:white;
        margin-top: 30px;
        font-family: "Microsoft YaHei UI";
        font-size: 18px;

    }
    .store-other {
        margin-top: 20px;
        margin-left: auto;
        margin-right: auto;
        height:80px;
        background-color: rgba(95, 110, 170, 0.4);
        border-radius: 10px;
        width:26%;
        margin-left: 20px;
        margin-top: 20px;
        color：white;
        float: left;
        line-height: 80px;
        text-align: center;
        color: white;


    }
    .store-other input{
        margin-right: 5px;
    }
    .store-other2 {
        margin-top: 20px;
        margin-left: auto;
        margin-right: auto;
        height:80px;
        background-color: white;
        border-radius: 10px;
        width:40%;
        margin-left: 20px;
        margin-top: 20px;

        float: left;
        line-height: 80px;
        text-align: center;
    }
    .form-head2{
        color: white;
        font-size: 16px;
        background-color: rgba(95, 110, 170, 0.4);
        border-radius: 5px;
        overflow: hidden;
        height:500px;
        float: left;
        width:100%;
        margin-top: 20px;
    }
    .store-other-img{
        width:50px;
        float: left;
        height:50px;
        margin-top: 14px;
        margin-left: 14px;
        border-radius: 10px;
    }
    .form-head2 input{
        width:10%;
        height:20px;
        line-height: 30px;


    }
    .bank{
        width:100%;
        height:50px;
        line-height: 30px;
        text-align: left;
        font-size: 16px;
        margin-left: 30px;
    }
    .form-input3-input{
        width:56%;

        height:32px;
        margin-top: 10px;
        line-height: 24px;
        padding: 5px;
    }
    .form-input3{
        height:42px;
    }
    .form-input4{
        width:100%;
        height:42px;
        float: left;
    }
    .picker-modal-inner{
        z-index:130;
    }
</style>

{/block}0
{block name="body"}

<form action="{:url('login/register')}" method="post" style="width:95%;margin: auto">
    <div class="form-head" style="height:440px;margin-top:10px;">
        <div class="form-input3" >
            <label style="color:white" for="name" style="width:30%" class="form-input3-label">商家名称:</label>
            <input style="border:solid 1px white;color:white" class="form-input3-input" id="name" name="name" type="text" value="" placeholder=" ">
        </div>
        <div class="form-input3" >
            <label style="color:white" for="name" style="width:30%" class="form-input3-label">经营内容:</label>
            <input style="border:solid 1px white;color:white" class="form-input3-input" id="scope" name="scope" type="text" value="" placeholder=" ">
        </div>
        <div class="form-input3" >
            <label style="color:white" for="name" style="width:30%" class="form-input3-label">折扣率:</label>
            <input style="border:solid 1px white;color:white" class="form-input3-input" id="discount_rate" name="discount_rate" type="text" value="" placeholder=" ">
        </div>
        <div class="form-input3" >
            <label style="color:white" for="name" style="width:30%" class="form-input3-label">返佣率:</label>
            <input style="border:solid 1px white;color:white" class="form-input3-input" id="rack_back_rate" name="rack_back_rate" type="text" value="" placeholder=" ">
        </div>
        <div class="form-input3" >
            <label style="color:white" for="name" style="width:30%" class="form-input3-label">联系电话:</label>
            <input style="border:solid 1px white;color:white" class="form-input3-input" id="contact_number" name="contact_number" type="text" value="" placeholder=" ">
        </div>
        <div class="form-input3" >
            <label style="color:white" for="name" style="width:30%" class="form-input3-label">商家地址:</label>
            <input style="border:solid 1px white;color:white" class="form-input3-input" id="position" name="position" type="text" value="" placeholder=" ">
        </div>
        <div class="form-input3">
            <label for="name" class="form-input3-label">商家分类:</label>
            <div style="width: 60%;height: 32px; display: inline-block; text-align: left; color: #dddddd;position: relative;">
                <span id="selectCategoryName" style="width: 75%; display: inline-block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;"></span>
                <a id="selectCategory" style="position: absolute; right: 10px;" href="javascript:void(0);">编辑</a>
            </div>
            <input class="form-input3-input" id="category_id" name="category_id" type="hidden" value="" placeholder=" ">
        </div>
        <div class="form-input3" >
            <label style="color:white" for="name" style="width:30%" class="form-input3-label">人均消费:</label>
            <input style="border:solid 1px white;color:white" class="form-input3-input" id="price" name="price" type="text" value="" placeholder=" ">
        </div>

        <div class="form-input3" >
            <label for="name"  class="form-input3-label">商家账号:</label>
            <input style="border:solid 1px white;" class="form-input3-input" id="account_mobile" name="account_mobile" type="text" value="" placeholder=" ">
        </div>
        <div class="form-input3" >
            <label for="name"  class="form-input3-label">商家密码:</label>
            <input style="border:solid 1px white;" class="form-input3-input" id="account_psw" name="account_psw" type="text" value="" placeholder=" ">
        </div>



    </div>
    <div class="form-head2" style="margin-bottom: 20px;float: left">
        <div class="form-input3" style="height:50px;">
            <label style="color:white" for="name" class="form-input3-label">银行卡号:</label>
            <input style="margin-top:10px;float:left;border:solid 1px white;color:white;width:60%;height:30px" class="form-input3-input" id="bank_card_no" name="bank_card_no" type="text" value="" placeholder=" ">
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd">选择省市区</div>
            <div class="weui-cell__bd">
                <input class="weui-input" style="width: 100%;height: 100%" id="select" type="button" placeholder="请选择所在省市区" value="北京 北京 东城">
            </div>
        </div>
        <div class="form-input3" style="height:50px;">
            <label style="color:white" for="kh" class="form-input3-label">开户行:</label>
            <input style="margin-top:10px;float:left;border:solid 1px white;color:white;width:60%;height:30px" class="form-input3-input" id="kh" name="kh" type="text" value="" placeholder=" ">
        </div>
        <div class="form-input3" style="height:50px;">
            <label style="color:white" for="bank_card_user" class="form-input3-label">持卡人姓名:</label>
            <input style="margin-top:10px;float:left;border:solid 1px white;color:white;width:60%;height:30px" class="form-input3-input" id="bank_card_user" name="bank_card_user" type="text" value="" placeholder=" ">
        </div>

        <label for="nongye"><div class="bank"><input style="margin-left: 26px;position:relative;bottom: 8px" type="radio" name="bank" id="nongye" value="中国农业银行" /><img style="width:180px;height:40px;margin-top: 24px;margin-left: 20px" src="__IMG__/1.png"> </div></label>
        <label for="jiaotong"><div class="bank"><input  style="margin-left: 26px;position:relative;bottom: 8px"  type="radio" name="bank" id="jiaotong" value="中国交通银行" /><img style="width:180px;height:40px;margin-top: 24px;margin-left: 20px" src="__IMG__/2.png"></div></label>
        <label for="jiaotong"><div class="bank"><input style="margin-left: 26px;position:relative;bottom: 8px" type="radio" name="bank" id="gongshang" value="中国工商银行" /><img style="width:180px;height:40px;margin-top: 24px;margin-left: 20px" src="__IMG__/3.png"></div></label>
        <label for="minsheng"><div class="bank"><input style="margin-left: 26px;position:relative;bottom: 8px" type="radio" name="bank" id="minsheng" value="中国银行" /><img style="width:180px;height:40px;margin-top: 24px;margin-left: 20px" src="__IMG__/4.png"></div></label>
        <label for="jianshe"><div class="bank"><input style="margin-left: 26px;position:relative;bottom: 8px" type="radio" name="bank" id="jianshe" value="中国建设银行" /><img style="width:180px;height:40px;margin-top: 24px;margin-left: 20px" src="__IMG__/5.png"></div></label>
    </div>
    <div class="form-body" style="text-align: center">
        <div class="input-window" style="background-size:cover;width:80%;margin-left:auto;margin-right:auto;">
            <img style="margin-top: 30px;height:30px;width:30px;margin-left: auto;margin-right: auto;margin-left: 2%" src="__IMG__/jia.png">
            <p style="color:white">上传门头照片</p>
            <input class="bb headimgurl" style="width:100%" type="file" accept="image/jpg,image/jpeg,image/png,image/gif"   />
            <input  type="hidden"  id="logo"  value="" />

        </div>
        <div class="input-window" style="background-size:cover;width:80%;margin-left:auto;margin-right:auto;">
            <img style="margin-top: 30px;height:30px;width:30px;margin-left: auto;margin-right: auto;margin-left: 2%" src="__IMG__/jia.png">
            <p style="color:white;">上传商家轮播图</p>
            <input class="bb headimgurl" style="width:100%" type="file" accept="image/jpg,image/jpeg,image/png,image/gif"   />
            <input  type="hidden"  id="main_img0"  value="" />
        </div>
        <div class="input-window" style="background-size:cover;width:80%;margin-left:auto;margin-right:auto;">
            <img style="margin-top: 30px;height:30px;width:30px;margin-left: auto;margin-right: auto;margin-left: 2%" src="__IMG__/jia.png">
            <p style="color:white;">上传商家轮播图</p>
            <input class="bb headimgurl" style="width:100%" type="file" accept="image/jpg,image/jpeg,image/png,image/gif"   />
            <input  type="hidden"  id="main_img1"  value="" />
        </div>

        <div class="input-window" style="background-size:cover;width:80%;margin-left:auto;margin-right:auto;">
            <img style="margin-top: 30px;height:30px;width:30px;margin-left: auto;margin-right: auto;margin-left: 2%" src="__IMG__/jia.png">
            <p style="color:white;">上传商家轮播图</p>
            <input class="bb headimgurl" style="width:100%" type="file" accept="image/jpg,image/jpeg,image/png,image/gif"   />
            <input  type="hidden"  id="main_img2"  value="" />
        </div>
        <div class="input-window" style="background-size:cover;width:80%;margin-left:auto;margin-right:auto;">
            <img style="margin-top: 30px;height:30px;width:30px;margin-left: auto;margin-right: auto;margin-left: 2%" src="__IMG__/jia.png">
            <p style="color:white;">上传商家轮播图</p>
            <input class="bb headimgurl" style="width:100%" type="file" accept="image/jpg,image/jpeg,image/png,image/gif"   />
            <input  type="hidden"  id="main_img3"  value="" />
        </div>
        <div class="input-window" style="background-size:cover;width:80%;margin-left:auto;margin-right:auto;">
            <img style="margin-top: 30px;height:30px;width:30px;margin-left: auto;margin-right: auto;margin-left: 2%" src="__IMG__/jia.png">
            <p style="color:white">上传商家辅图</p>
            <input class="bb headimgurl" style="width:100%" type="file" accept="image/jpg,image/jpeg,image/png,image/gif"   />
            <input  type="hidden"  id="main_img_small"  value="" />
        </div>
    </div>

    <label for="ali" class="store-other">
         <input id="zero" checked="checked" name="first_offer" value="0" type="radio">0元
    </label>
    <label for="ali" class="store-other">
        <input id="ali"  name="first_offer" value="500" type="radio">5元
    </label>

    <label for="weixin" class="store-other">
        <input id="weixin"  name="first_offer" value="1000" type="radio">10元
    </label>

    <label for="weixin" class="store-other">
        <input id="twenty"  name="first_offer" value="2000" type="radio">20元
    </label>
    <div class="form-input4" style="height:50px;">
        <label style="color:white" for="name" class="form-input3-label">首次优惠数:</label>
        <input style="margin-top:10px;float:left;border:solid 1px white;color:white;width:60%;height:30px" class="form-input3-input" id="first_offer_num" name="first_offer_num" type="number" value="" placeholder=" ">
    </div>
    <p style="float: left;color:white;margin-left: 2em">个人创业剩余优惠金:{$preferential_money/100}</p>
    <div style="position:fixed;bottom:0;left:0;width:100%;height:50px;z-index: 120;">
        <!--<button id="delete" class="bottom-btn botton1" type="button">删除</button>-->
        <button id="submit" class="bottom-btn botton2" type="button">提交</button>
    </div>


</form>
<div style="width:100%;height:70px;float: left">

</div>
<div id="shopCategory" style="display: none"></div>
<div style="float:left;height:50px;margin-top: 10px;width: 100%;"></div>
{/block}
{block name="footer"}
<script type="text/javascript" src="__JS__/public.js"></script>
<script>
    $("#select").cityPicker({
        title: "请选择所在省市区",
        onChange: function (picker, values, displayValues) {
        },
        onClose: function(){
            var keyword =  $("#select").val();
        }
    });
    $(function(){
        $('.headimgurl').change(function () {
            var v_this = $(this);
            lrz(this.files[0],{width:640,fieldName:"image"}).then(function (rst) {
                var formdata = new FormData();
                v_this.parent().css("background-image","url("+rst.base64+")");//无论是否上传成功都显示
                url = "__BASE__/web.php/file/upload_picture_base64";
                formdata.append("image", rst.base64);
                $.ajax({
                    url : url,
                    type : 'post',
                    data : formdata,
                    contentType : false,
                    processData : false,
                    dataType : "json",
                    success : function(data) {
                        if (data.status == true) {
                            $.toast("图片上传成功");
                            v_this.next().val(data.info[0]['id']);
                        }
                    },
                    error:function(){
                        $.toast("图片上传失败");
                    }
                });
                return false;
            })
        });
    })
    $('#submit').click(function () {
            var preferential_money = "{$preferential_money}";
            if($('#account_mobile').val() == "" && $('#account_mobile').val().length != 11){
                $.toast("用户名必须为11位手机号",'cancel');
            }
            if($('#account_psw').val().length<6){
                $.toast("密码长度不可以小于6位",'cancel');
            }
            if($('#category_id').val() == ""){
                $.toast("请编辑商家分类",'cancel');
            }
            if($('input[name="first_offer"]:checked ').val()*$('#first_offer_num').val()>preferential_money){
                return false;
            }

            var imgs = new Array();
            if($('#main_img0').val()!=0){
                imgs.push($('#main_img0').val());
            }
            if($('#main_img1').val()!=0){
                imgs.push($('#main_img1').val());
            }
            if($('#main_img2').val()!=0){
                imgs.push($('#main_img2').val());
            }
            if($('#main_img3').val()!=0){
                imgs.push($('#main_img3').val());
            }

        imgs_json = JSON.stringify(imgs);
            var body  ={
                platform_id:"{$platform_id}",
                price:$('#price').val(),
                name:$('#name').val(),
                scope:$('#scope').val(),
                discount_rate:$('#discount_rate').val(),
                rack_back_rate:$('#rack_back_rate').val(),
                contact_number:$('#contact_number').val(),
                position:$('#position').val(),
                account_mobile:$('#account_mobile').val(),
                account_psw:$('#account_psw').val(),
                logo:$('#logo').val(),
                main_img:imgs_json,
                main_img_small:$('#main_img_small').val(),
                first_offer: $('input[name="first_offer"]:checked ').val(),
                first_offer_num:$('#first_offer_num').val(),
                bank_card_name:$('input[name="bank"]:checked').val(),
                bank_card_no:$('#bank_card_no').val(),
                bank_card_user:$('#bank_card_user').val(),
                pca:$('#select').val(),
                kh:$('#kh').val(),
                category_id: $('#category_id').val()
            };
            var $this = $(this);
            $this.addClass('weui-btn_disabled').attr('disabled','disabled');
            ajax_post(getBaseUrl()+'web.php/extension/add_shop',jQuery.param(body),{
                success:function(data){
                    $.toast("添加成功",'success');
                    $this.removeClass('weui-btn_disabled').removeAttr("disabled");
                    setTimeout(
                        function(){
                            history.back(-1);
                        }
                        ,1500);
                },
                error:function(data){
                    $.toptip(data.msg, 'error');
                    $this.removeClass('weui-btn_disabled').removeAttr("disabled");
                }
            })


    });
</script>
<script>
    $('#selectCategory').click(function () {
        $('body').addClass('scroll-hidden');
        $('html').addClass('scroll-hidden');
//        $('#shopCategory').css("top", document.documentElement.scrollTop);
        $('#shopCategory').show();
    });
    window.baseImgSrc = "__BASE__/static/web/img";
    const cateItems = {$category};
</script>
<script src="__JS__/editShop/common.js?v201710191152"></script>
{/block}